using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class req_testsMap : EntityTypeConfiguration<req_tests>
    {
        public req_testsMap()
        {
            // Primary Key
            this.HasKey(t => t.id);

            // Properties
            this.Property(t => t.name)
                .HasMaxLength(50);

            this.Property(t => t.item_id)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("req_tests");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.name).HasColumnName("name");
            this.Property(t => t.req_id).HasColumnName("req_id");
            this.Property(t => t.note).HasColumnName("note");
            this.Property(t => t.item_id).HasColumnName("item_id");
            this.Property(t => t.cat_id).HasColumnName("cat_id");
            this.Property(t => t.catatt_id).HasColumnName("catatt_id");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
            this.Property(t => t.price).HasColumnName("price");
            this.Property(t => t.userid).HasColumnName("userid");
            this.Property(t => t.Posted).HasColumnName("Posted");
            this.Property(t => t.needtoprint).HasColumnName("needtoprint");
            this.Property(t => t.OrderID).HasColumnName("OrderID");

            // Relationships
            this.HasRequired(t => t.Item)
                .WithMany(t => t.req_tests)
                .HasForeignKey(d => d.item_id);
            this.HasOptional(t => t.ItmCatAttVal)
                .WithMany(t => t.req_tests)
                .HasForeignKey(d => d.catatt_id);
            this.HasRequired(t => t.ItmCateg)
                .WithMany(t => t.req_tests)
                .HasForeignKey(d => d.cat_id);
            this.HasRequired(t => t.Name1)
                .WithMany(t => t.req_tests)
                .HasForeignKey(d => d.userid);
            this.HasRequired(t => t.request)
                .WithMany(t => t.req_tests)
                .HasForeignKey(d => d.req_id);

        }
    }
}
